<?php
$total_lances = 0;
$lote = false;
if ($lances) :
    $lote = $lances ['0'];
    $total_lances = $lote->TOTAL_LANCES;
endif;
?>
<div class="box-classif-total">
    <span class="text-classif-total">CLASSIFICACAO DE LANCES TOTAL:</span>
    <span class="text-total-lances"><?php echo $total_lances; ?> LANCES(S)</span>
</div>
<div class="box-classif-total">
    <span class="text-classif-total">MAIOR LANCE</span> 
</div>

<?php if ($last_lances) : ?>
    <div class="table-responsive">
        <table style="font-size: 11px;" class="table table-condensed table-bordered">
            <thead>
                <tr>
                    <th>LOGIN</th>
                    <th>DATA</th>
                    <th>MAIOR LANCE</th>
                    <th>COMISSAO</th>
                    <th>TOTAL DO LOTE</th>
                </tr>
            </thead>
            <tbody>

                <?php $last_lote = $last_lances['0']; ?>
                <tr class="success">
                    <td><?php echo $last_lote->LOGIN; ?>-<?php echo $last_lote->USER_CIDADE; ?></td>
                    <td><?php echo auto_format_data($last_lote->CRIADO, '-', '/') . '(BR)'; ?></td>
                    <td><?php echo number_format($last_lote->TOTAL, 2, ',', '.') . '(BRL)';
                ?></td>
                    <td><?php echo number_format($last_lote->COMISSAO, 2, ',', '.') . '(BRL)'; ?></td>
                    <td><?php echo number_format($last_lote->TOTAL_COMISSAO, 2, ',', '.') . '(BRL)'; ?></td>
                </tr>


            </tbody>
        </table>
    </div>

<?php endif; ?>

<div class="box-classif-total">
    <span class="text-classif-total">LANCES SUPERADOS</span> <!--<span
        class="text-total-lances2"> </span> -->
</div>

<?php if ($last_lances) : ?>
    <table style="font-size: 11px;" class="table table-condensed table-striped">
        <thead>
            <tr>
                <th>LOGIN</th>
                <th>DATA</th>
                <th>VALOR DO LANCE</th>
                <th>COMISSAO</th>
                <th>TOTAL DO LOTE</th>
            </tr>
        </thead>
        <tbody>

            <?php foreach ($last_lances as $plote): ?>
                <tr>
                    <td><?php echo $plote->LOGIN; ?>-<?php echo $plote->USER_CIDADE; ?></td>
                    <td><?php echo auto_format_data($plote->CRIADO, '-', '/') . '(BR)'; ?></td>
                    <td><?php echo number_format($plote->TOTAL, 2, ',', '.');?></td>
                    <td><?php echo number_format($plote->COMISSAO, 2, ',', '.'); ?></td>
                    <td><?php echo number_format($plote->TOTAL_COMISSAO, 2, ',', '.'); ?></td>
                </tr>
            <?php endforeach; ?>

        </tbody>
    </table>

<?php endif; ?>


<div class="box-classif-total">
    <span class="text-classif-total">LANCES CONSOLIDADOS TOTAL:</span> <span
        class="text-total-lances2"><?php echo (int) count($lances); ?> COMPRADOR(ES)</span>
</div>
<table style="font-size: 11px;" class="table table-condensed">
    <thead>
        <tr>
            <th>LOGIN</th>
            <th>QUANTIDADES DE LANCES</th>
            <th>MAIOR LANCE</th>
            <th>COMISSAO</th>
            <th>TOTAL DO LOTE</th>
        </tr>
    </thead>
    <tbody>
        <?php if ($lances) : ?>
            <?php foreach ($lances as $row): ?>
                <tr>
                    <td><?php echo $row->LOGIN; ?> - <?php echo $row->USER_CIDADE; ?></span>

                    <td><?php echo $row->LANCES; ?></span>

                    <td><?php
                        echo number_format($row->LANCE, 2, ',', '.');
                        ?></td>
                    <td><?php echo number_format($row->COMISSAO, 2, ',', '.'); ?></td>
                    <td><?php echo number_format($row->TOTAL_COMISSAO, 2, ',', '.'); ?></td>
                </tr>
            <?php endforeach; ?>
        <?php endif; ?>
    </tbody>
</table>